<template>
	<view class="container">
		<view v-if='collectionList' style="background: #FFFFFF;border-radius: 10upx;width: 330upx;margin: 10upx;padding: 10upx;" v-for="(item,index) in collectionList" :key='index' @click="goDetail(item.goodsId)">
			<image :src="item.imgUrl" style="width: 330upx;height: 330upx;"></image>
			<view style="width: 330upx;">
				<view class="name">{{item.goodsName}}</view>
				<view style="display: flex;justify-content: space-between;margin-top: 10upx;">
					<view>¥{{item.price}}</view>
					<view><uni-icon type="star" size='30'></uni-icon>{{item.collectCount}}</view>
				</view>
			</view>
		</view>
		<view v-else style="color: #999999;margin-top: 100upx;text-align: center;">暂无收藏</view>
	</view>
</template>
<script>
	import {
		get,
		post,
		showToast
	} from '../../js/common';
	export default{
		data(){
			return {
				collectionList:{}
			}
		},
		onShow() {
			this.getCollection()
		},
		methods: {
			getCollection() {
				let params = {
					userId: uni.getStorageSync('userId')
				}
				post('mobileapi/mobile/member/usercenter/userShowCollect',params).then(res =>{
					if(res.page){
						this.collectionList = res.page.list
					}else{
						this.collectionList = {}
					}
				})
			},
			goDetail(id) {
				uni.navigateTo({
					url: '/pages/commodity/index?id=' + id
				})
			},
		},
	}
</script>
<style>
	.container{
		display: flex;
		flex-wrap: wrap;
		font-size: 30upx;
		padding: 10upx;
	}
	
	.detail{
		background: #FFFFFF;
		border-radius: 10upx;
		width: 340upx;
		margin: 10upx;
	}
	
	.name{
		height: 80upx;
		line-height: 40upx;
		font-size: 28upx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}
</style>